import { getLevelFirstJson, getLevelZeroJson, getSelectDataMapList, getTenantID } from '@/utils';
import { ContacterAPI } from '../common/type';
import { ILoadMapTypeAll } from '@/common';

/* 获取数据字典搜索数组 */
const getSearchList = (loadMdicMapList: Record<string, any>, switchObj: Record<string, any>): ContacterAPI.ISearchList => {
  let orgDeptList: any[] = [];
  if (switchObj?.queryType == 0) {
    orgDeptList = getLevelZeroJson();
  } else if (switchObj?.queryType == 1) {
    orgDeptList = getLevelFirstJson();
  }

  let nationData = getSelectDataMapList(
    loadMdicMapList?.data?.obj?.[`${getTenantID()}${ILoadMapTypeAll.NATION_TYPE}`],
    'name',
    'id',
  );
  let politicalData = getSelectDataMapList(
    loadMdicMapList?.data?.obj?.[`${getTenantID()}${ILoadMapTypeAll.POLITICAL_OUTLOOK}`],
    'name',
    'id',
  );
  let educateLevelData = getSelectDataMapList(
    loadMdicMapList?.data?.obj?.[`${getTenantID()}${ILoadMapTypeAll.EDUCATION_LEVEL}`],
    'name',
    'id',
  );

  let switchArr: ContacterAPI.ISearchList = [
    {
      name: 'name',
      placeholder: '姓名',
      label: '姓名',
      componentType: 'Input',
      allowClear: true,
      md: 4,
      sm: 24,
      whetherSenior: false,
    },
    {
      name: 'phoneMobile',
      placeholder: '联系方式',
      label: '联系方式',
      componentType: 'Input',
      allowClear: true,
      md: 4,
      sm: 24,
      whetherSenior: false,
    },
    {
      name: 'emailNum',
      placeholder: '邮箱编号',
      label: '邮箱编号',
      componentType: 'Input',
      allowClear: true,
      md: 4,
      sm: 24,
      whetherSenior: false,
    },
    {
      name: 'companyName',
      placeholder: '所在公司',
      label: '所在公司',
      componentType: 'Input',
      md: 4,
      sm: 24,
      whetherSenior: false,
    },
    {
      name: 'deptName',
      placeholder: '所在部门',
      label: '所在部门',
      componentType: 'Input',
      md: 4,
      sm: 24,
      whetherSenior: false,
    },
    {
      name: 'positionName',
      placeholder: '当前职务',
      label: '当前职务',
      componentType: 'Input',
      md: 4,
      sm: 24,
      whetherSenior: false,
    },
    {
      name: 'phoneOffice',
      placeholder: '办公电话',
      label: '办公电话',
      componentType: 'Input',
      md: 6,
      sm: 24,
      whetherSenior: true,
    },
    {
      name: 'nationType',
      placeholder: '民族',
      label: '民族',
      componentType: 'Select',
      dataSource: nationData,
      allowClear: true,
      md: 6,
      sm: 24,
      whetherSenior: true,
    },
    {
      name: 'politicalType',
      placeholder: '政治面貌',
      label: '政治面貌',
      componentType: 'Select',
      dataSource: politicalData,
      allowClear: true,
      md: 6,
      sm: 24,
      whetherSenior: true,
    },
    {
      name: 'educateLevel',
      placeholder: '最高学历',
      label: '最高学历',
      componentType: 'Select',
      dataSource: educateLevelData,
      allowClear: true,
      md: 6,
      sm: 24,
      whetherSenior: true,
    },
    {
      name: 'hobby',
      placeholder: '兴趣爱好',
      label: '兴趣爱好',
      componentType: 'Input',
      allowClear: true,
      md: 6,
      sm: 24,
      whetherSenior: true,
    },
    {
      name: 'createTime',
      placeholder: '创建',
      label: '创建时间',
      componentType: 'RangePicker',
      md: 6,
      sm: 24,
      whetherSenior: true,
    },
  ];

  if (switchObj?.queryType != 3) {
    switchArr?.push({
      name: 'createFormName',
      placeholder: '创建',
      label: '创建',
      componentType: 'DeptAndUser',
      dataSource: orgDeptList,
      allowClear: true,
      md: 6,
      sm: 24,
      whetherSenior: true,
      formOrgType: {
        COMP: 'createCompanyID',
        DEPT: 'createDepartmentID',
        POS: 'createPositionID',
        USER: 'createrID',
      }, //获取组织机构表单name, componentType: 'DeptAndUser', 必传
    });
  }
  return switchArr;
};

export { getSearchList };
